package com.example.javaspringweb.config;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@RestController
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("home_page");

        registry.addViewController("/body/login").setViewName("login");
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/homepage.html").setViewName("dashboard");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())
                .addPathPatterns("/homepage.html","/dataB","/userA");
//                .excludePathPatterns("/",
//                        "/home_page.html",
//                        "/login.html",
//                        "/body/word",
//                        "/body/pie",
//                        "/body/funnel",
//                        "/body/bar",
//                        "/body/map",
//                        "/body/page",
//                        "/body/login",
//                        "/user/login",
//                        "/css/**",
//                        "/img/**",
//                        "/js/**");
    }
}
